package yaq.mini.weibo.leafwb.mapper;

import yaq.mini.weibo.leafwb.pojo.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CommentMapper {
    List<Comment> getFullListCommentByAID(String articleId);

    @Select("select * from comment where commentId = #{commentId}")
    Comment getCommentByID(String commentId);

    @Select("select * from comment where articleId = #{articleId} order by commentTime desc")
    List<Comment> getListCommentByAID(String articleId);

    @Insert("insert into comment values(#{commentId},#{articleId},#{userId},#{commentTime},#{content})")
    int insert(Comment comment);

    @Update("update comment set content=#{content} where commentId=#{commentId}")
    int update(Comment comment);

    @Delete("delete from comment where articleId=#{articleId}")
    int deleteByAID(String articleId);

    @Delete("delete from comment where commentId=#{commentId}")
    int deleteByID(String commentId);
}
